package com.qf.mybatisplus.rabbitMQ;
import com.qf.mybatisplus.config.rabbitMQConfig.RabbitMQCommonConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
* @Description 死信消费者
* @Param
* @Author 12136
* @Date 16:19 2021/11/24
* @return 
**/
//@Component
public class DLXConsumer {

    @RabbitListener(queues = {RabbitMQCommonConfig.DLX_DIRECT_QUEUE})
    public void getMessage(Channel channel, Message message) throws IOException {

        System.err.println("死信队列测试接受延迟消息"+ new String(message.getBody()) +  ":" +new Date().toLocaleString());

        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}